using Microsoft.AspNetCore.Http;
using System.Globalization;
using System.Threading.Tasks;
using System;

namespace MiddlerWare
{
    public static class RequestCultureMiddlewareExtensions
    {
        public static IApplicationBuilder UseRequestCulture(
            this IApplicationBuilder builder)
        {
            return builder.UseMiddleware<RequestCultureMiddleware>();
        }
    }
    public class RequestTestMiddleware
    {
        private readonly RequestDelegate _next;

        public RequestTestMiddleware(RequestDelegate next)
        {
            _next = next;
        }

        public Task Invoke(HttpContext context)
        {
            var cultureQuery = context.Request.Query["culture"];
            
            // Call the next delegate/middleware in the pipeline
            return this._next(context);
        }
    }
}